home *** CD-ROM | disk | FTP | other *** search
- class CPhitGameCodeCreate extends CPhitGame
- {
- var _arrHostsAwaitingNextOnEnterFrame;
- var _arrFieldHosts;
- var _createStartWaitUpdate = 10000000;
- var _iRetainedStartLevel = undefined;
- function CPhitGameCodeCreate()
- {
- super();
- }
- function FirstFrameInitialize()
- {
- this._arrHostsAwaitingNextOnEnterFrame = new Array();
- this._iRetainedStartLevel = _root._iStartLevel;
- super.FirstFrameInitialize();
- }
- function FinishFieldSequence()
- {
- FreshDebug.Trace("CPhitGameCodeCreate.FinishFieldSequence() _iLevel=" + this._iLevel + ", _iRetainedStartLevel=" + this._iRetainedStartLevel);
- if(this._iRetainedStartLevel != undefined)
- {
- this._iLevel = this._iRetainedStartLevel;
- this._iRetainedStartLevel = undefined;
- }
- FreshDebug.Assert(this._iLevel < this._arrFieldHosts.length,"_iLevel < _arrFieldHosts.length");
- FreshDebug.Trace("using fieldhost " + this._iLevel);
- this._fieldHost = this._arrFieldHosts[this._iLevel];
- this._field = this._fieldHost._field;
- this._fieldHost.PlayAppear();
- }
- function onEnterFrame()
- {
- if(this.m_nUpdates > this._createStartWaitUpdate + 2 && this._arrHostsAwaitingNextOnEnterFrame.length > 0)
- {
- var _loc4_ = 0;
- while(_loc4_ < this._arrHostsAwaitingNextOnEnterFrame.length)
- {
- var _loc3_ = this._arrHostsAwaitingNextOnEnterFrame[_loc4_];
- _loc3_.resume(_loc3_.host,_loc3_.width,_loc3_.height);
- this.ScaleField(_loc3_.host);
- _loc4_ = _loc4_ + 1;
- }
- this._arrHostsAwaitingNextOnEnterFrame.splice(0);
- this.FinishFieldSequence();
- }
- super.onEnterFrame();
- }
- function StartNextLevel()
- {
- this._iLevel = this._iLevel + 1;
- FreshDebug.Trace("moving to level " + this._iLevel);
- _root._presentation.StoreLastPlayedLevel(this._iLevel);
- if(this._arrFieldHosts[this._iLevel] != undefined)
- {
- FreshDebug.Trace("Using prebuilt level.");
- this._fieldHost = this._arrFieldHosts[this._iLevel];
- this._field = this._fieldHost._field;
- this._isFieldSolved = false;
- this._doneShuffling = true;
- this._fieldHost.PlayAppear();
- }
- else
- {
- this.StartFieldSequence();
- }
- }
- function CreatePlayingField(iLevel, width, height, resumeFn)
- {
- var _loc3_ = iLevel;
- this.attachMovie("Field Host","fieldHost" + _loc3_,_loc3_);
- var _loc2_ = CFieldHost(this["fieldHost" + _loc3_]);
- this._arrFieldHosts[iLevel] = _loc2_;
- this._arrHostsAwaitingNextOnEnterFrame.push({host:_loc2_,resume:resumeFn,width:width,height:height});
- FreshDebug.Assert(_loc2_ != undefined,"_fieldHost != undefined");
- FreshDebug.Assert(_loc2_._field != undefined,"_fieldHost._field != undefined");
- this._doneShuffling = true;
- this._isFieldSolved = false;
- return _loc2_._field;
- }
- function StartFieldSequence()
- {
- var _loc4_ = "StartCreatingLevel" + this._iLevel;
- if(_root[_loc4_] != undefined && _root[_loc4_] instanceof Function)
- {
- FreshDebug.Trace("Using creation function " + _loc4_);
- this._createStartWaitUpdate = this.m_nUpdates;
- _root[_loc4_]();
- }
- else
- {
- FreshDebug.Trace("Found no creation function " + _loc4_);
- super.StartFieldSequence();
- }
- }
- }
-